import java.util.Iterator;
import java.util.TreeSet;

public class Demo2Set {
    public static void main(String[] args) {
        TreeSet<String> set = new TreeSet<>();
        set.add("abc");
        set.add("def");
        set.add("hello");
        set.add("hello");

        Iterator<String> it = set.iterator();
        while(it.hasNext()) {
            System.out.println(it.next()+ " ");
        }
    }
}
